package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Comment;
import com.dragon.repository.entity.Follow;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.ALWAYS)
public class FollowDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "客户ID")
    private Integer customerId;

    @ApiModelProperty(value = "跟进名称")
    private String followName;

    @ApiModelProperty(value = "跟进内容")
    private String content;

    @ApiModelProperty(value = "跟进类型：0电话回访，1线下拜访，2线上联系")
    private String type;

    @ApiModelProperty(value = "跟进进度")
    private String progress;

    @ApiModelProperty(value = "状态：0 待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "下次联系时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date nextTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "跟进人ID")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "客户名称")
    private String customerName;

    @ApiModelProperty(value = "申请人名称")
    private String applicantName;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "评论")
    private List<Comment> commentList;

    @ApiModelProperty(value = "附件列表")
    private List<OtherFile> otherFileList;




    public FollowDTO() {}

    public FollowDTO(Follow entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static FollowDTO convert(Follow entity) {
        return new FollowDTO(entity);
    }

    public static List<FollowDTO> convertList(List<Follow> list) {
        List<FollowDTO> resultList = new ArrayList<>();
        for (Follow entity : list) {
            resultList.add(new FollowDTO(entity));
        }
        return resultList;
    }}
